//
//  WYRFiveViewController.m
//  10-21-快速搭建框架
//
//  Created by lkx0 on 16/10/25.
//  Copyright © 2016年 lkx0. All rights reserved.
//

#import "WYRFiveViewController.h"
#import "WYROneViewController.h"

@interface WYRFiveViewController ()

//设置两个全局变量
@property (nonatomic, strong) UITextField * passWordField;
@property (nonatomic, strong) UITextField * confirmPassWordField;

@end

@implementation WYRFiveViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor=[UIColor whiteColor];
    [self setRegistLable];
    [self setCountLable];
    [self setCountField];
    [self setPassWordLable];
    [self setPassWordField];
    [self setConfirmPassWordLable];
    [self setConfirmPassWordField];
    [self setRegistButton];
    // Do any additional setup after loading the view.
}

-(void)setRegistLable{
    UILabel * registLable=[[UILabel alloc]initWithFrame:CGRectMake(105, 100, 220, 60)];
    registLable.backgroundColor=[UIColor greenColor];
    registLable.text=@"注册界面";
    registLable.textAlignment=NSTextAlignmentCenter;
    registLable.font=[UIFont systemFontOfSize:35];
    [self.view addSubview:registLable];
}

-(void)setCountLable{
    UILabel * countLable=[[UILabel alloc]initWithFrame:CGRectMake(50, 190, 90, 45)];
    //   countLable.backgroundColor=[UIColor blueColor];
    countLable.text=@"账号";
    countLable.textAlignment=NSTextAlignmentCenter;
    countLable.font=[UIFont systemFontOfSize:25];
    [self.view addSubview:countLable];
    
}


-(void)setCountField{
    UITextField * countField=[[UITextField alloc]initWithFrame:CGRectMake(160, 190, 220, 45)];
    countField.borderStyle=UITextBorderStyleLine;
    countField.layer.borderWidth=2.0f;
    countField.placeholder=@"请输入账号";
    countField.textAlignment=NSTextAlignmentCenter;
    [self.view addSubview:countField];
}

-(void)setPassWordLable{
    UILabel * passWordLable=[[UILabel alloc]initWithFrame:CGRectMake(50, 265, 90, 45)];
    //   countLable.backgroundColor=[UIColor blueColor];
    passWordLable.text=@"密码";
    passWordLable.textAlignment=NSTextAlignmentCenter;
    passWordLable.font=[UIFont systemFontOfSize:25];
    [self.view addSubview:passWordLable];
}

-(void)setPassWordField{
    UITextField * passWordField=[[UITextField alloc]initWithFrame:CGRectMake(160, 265, 220, 45)];
    passWordField.borderStyle=UITextBorderStyleLine;
    passWordField.placeholder=@"请输入密码";
    passWordField.textAlignment=NSTextAlignmentCenter;
    passWordField.secureTextEntry=YES;
    _passWordField=passWordField;
    [self.view addSubview:passWordField];
}

-(void)setConfirmPassWordLable{
    UILabel * confirmPassWordLable=[[UILabel alloc]initWithFrame:CGRectMake(40, 340, 90, 45)];
    //   countLable.backgroundColor=[UIColor blueColor];
    confirmPassWordLable.text=@"确认密码";
    confirmPassWordLable.textAlignment=NSTextAlignmentCenter;
    confirmPassWordLable.font=[UIFont systemFontOfSize:22];
    [self.view addSubview:confirmPassWordLable];
}

-(void)setConfirmPassWordField{
    UITextField * confirmPassWordField=[[UITextField alloc]initWithFrame:CGRectMake(160, 340, 220, 45)];
    confirmPassWordField.borderStyle=UITextBorderStyleLine;
    confirmPassWordField.placeholder=@"请确认密码";
    confirmPassWordField.textAlignment=NSTextAlignmentCenter;
    confirmPassWordField.secureTextEntry=YES;
    _confirmPassWordField=confirmPassWordField;
    [self.view addSubview:confirmPassWordField];
}

-(void)setRegistButton{
    UIButton * registButton=[[UIButton alloc]initWithFrame:CGRectMake(150, 420, 100, 45)];
    registButton.backgroundColor=[UIColor grayColor];
    [registButton setTitle:@"注册" forState:UIControlStateNormal];
    [registButton setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];
    [registButton addTarget:self action:@selector(registClilck) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:registButton];
    
}

-(void)registClilck{
    if([_passWordField.text isEqualToString:_confirmPassWordField.text]){
        NSLog(@"%@,%@",_passWordField.text,_confirmPassWordField.text);
        NSLog(@"完成注册");
        WYROneViewController * oneView=[[WYROneViewController alloc]init];
        [self.navigationController pushViewController:oneView animated:YES];
    }    else{
        UIAlertView * alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"密码错误" delegate: self cancelButtonTitle:@"返回" otherButtonTitles:nil];
        [alert show];
    }
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
